package com.example.controller;


import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
public class RestFulController {
    @GetMapping("/calc/{num1}/{num2}")
    @ResponseBody
    public String test1(@PathVariable int num1, @PathVariable int num2) {
        int res = num1 + num2;
        return String.valueOf(res);
    }

    @PostMapping("/calc/{num1}/{num2}")
    @ResponseBody
    public String test2(@PathVariable int num1, @PathVariable int num2) {
        int res = num1 - num2;
        return String.valueOf(res);
    }

    @RequestMapping("/text3")
    public String test3(Model model){
        model.addAttribute("message","Hello");
        return "redirect:/index.jsp";
    }

    @GetMapping("/aaa")
    @ResponseBody
    public String text() {
        return "aaa";
    }
}
